package com.leon.registerclient;

import static java.lang.Thread.interrupted;

public class InterruptDemo {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            while (!interrupted()) {
                System.out.println("线程1在执行工作......");
            }
        });
        thread.start();
        Thread.sleep(1000L);
        System.out.println(thread.isInterrupted());
        thread.interrupt();
        System.out.println(thread.isInterrupted());
    }
}
